home *** CD-ROM | disk | FTP | other *** search
- unit stubexeu;
-
- interface
-
- uses
- SysUtils, WinProcs, WinTypes, Messages, Classes, Graphics, Controls, Forms, Dialogs,
- StdCtrls;
-
- type
- TForm1 = class(TForm)
- LoadLibBtn: TButton;
- FreeLibBtn: TButton;
- procedure LoadLibBtnClick(Sender: TObject);
- procedure FreeLibBtnClick(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- DllLib: THandle;
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.DFM}
-
- procedure TForm1.LoadLibBtnClick(Sender: TObject);
- begin
- OutputDebugString('APP: "Load Library" button pressed'#13#10);
- DllLib := LoadLibrary('stubdll.dll');
- if DllLib <> 0 then
- begin
- LoadLibBtn.Enabled := False;
- FreeLibBtn.Enabled := True;
- end
- else
- raise EFOpenError.Create('No StubDll');
- end;
-
- procedure TForm1.FreeLibBtnClick(Sender: TObject);
- begin
- OutputDebugString('APP: "Free Library" button pressed'#13#10);
- if DllLib <> 0 then
- begin
- FreeLibrary(DllLib);
- LoadLibBtn.Enabled := True;
- FreeLibBtn.Enabled := False;
- end;
- end;
-
- var
- OldExitProc: Pointer;
-
- procedure NewExitProc; far;
- begin
- ExitProc := OldExitProc;
- OutputDebugString('APP: Exit procedure added the old fashioned way (ExitProc)'#13#10);
- end;
-
- procedure NewerExitProc; far;
- begin
- OutputDebugString('APP: Exit procedure added with AddExitProc'#13#10);
- end;
-
- initialization
- OutputDebugString('APP: Unit initialisation section'#13#10);
- OldExitProc := ExitProc;
- ExitProc := @NewExitProc;
- AddExitProc(NewerExitProc);
- end.
-